package mainService.services;

import java.util.ArrayList;
import java.util.Collections;

import mainService.HTTPService;
import mainService.ServiceParams;
import mainService.data.IpClient;
import mainService.data.UsersConnected;
import mainService.data.Utente;

/**
 * Servizio di Sintesi dei task per un progetto.
 * 
 * @author Daniel Procop, Mattia Grecchi
 */
public class SintesiTaskProjectService extends ReadingServices implements
		HTTPService {

	public SintesiTaskProjectService() {
		super();
	}

	static private ArrayList<String> campiXML = new ArrayList<String>();

	static {
		Collections.addAll(campiXML, "id_task", "total_hours", "worked_hours",
				"name", "description", "isCompleted", "expdate");
	}

	@Override
	public ArrayList<String> getServiceResult(ServiceParams params) {

		Utente user = UsersConnected.getUsersConnected().getUtente(
				IpClient.getSingleton().getIp());
		int id_project = user.getId_project();

		String qry = "select id_task, name, total_hours, worked_hours, description, isCompleted, expdate from tasks where id_project='"
				+ id_project + "'";
		return getResult(qry, campiXML);
	}

}
